package com.newlink.building.userinfo.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Lifecycle
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.newlink.building.common_base.base.BaseFragment
import com.newlink.building.userinfo.activity.tabArray

//private const val NUM_TABS = 2

/**
 * @Author: Jake
 * @Date: 2023-12-11
 * @Description:
 */
class Module_UserInfo_ViewPagerAdapter(fragmentManager: FragmentManager, lifecycle: Lifecycle) :
    FragmentStateAdapter(fragmentManager, lifecycle) {

    private var mList = mutableListOf<BaseFragment>()
    fun setFragments(list: MutableList<BaseFragment>) {
        this.mList = list
        notifyDataSetChanged()
    }

    override fun getItemCount(): Int {
        return tabArray.size
    }

    override fun createFragment(position: Int): Fragment {
        return when (position) {
            1 -> mList[1]
            else -> mList[0]
        }
    }
}